#include <cmath>
#include "Defs.h"

unsigned convertir_a_num(unsigned char* rep_cad){
//	std::string::iterator it;
//	size_t exp=rep_cad.length()-1;
	size_t exp=0;
	unsigned res=0;
/*  	for ( it=rep_cad.begin() ; it != rep_cad.end(); ++it){
  		res+=(num_val(*it))*pow(BASE_CADENA,exp);
  		--exp;
  	}*/
  	for ( int i=0 ; i< SUB_BLOCK_SIZE; ++i){
//  		res+=(num_val(rep_cad[i]))*pow(BASE_CADENA,exp);
//		std::cout<<(unsigned)rep_cad[i]<<std::endl;
		res+=((unsigned)rep_cad[i])*pow(BASE_CADENA,exp);
  		++exp;
  	}
//  	std::cout<<"res: "<<res<<std::endl;
  	return res;
}
unsigned F(unsigned x,unsigned y,unsigned z){
	return (x & y) | (~x & z);
}
unsigned G(unsigned x,unsigned y,unsigned z){
	return (x & z) | (y & ~z);
}
unsigned H(unsigned x,unsigned y,unsigned z){
	return x ^ y ^ z;
}
unsigned I(unsigned x,unsigned y,unsigned z){
	return y ^ (x | ~z);
}
size_t sub_bloque_para_F(size_t& idx){
	return idx;
}
size_t sub_bloque_para_G(size_t& idx){
	return (5*idx+1) % 16;
}
size_t sub_bloque_para_H(size_t& idx){
	return (3*idx+5) % 16;
}
size_t sub_bloque_para_I(size_t& idx){
	return (7*idx) % 16;
}



